﻿using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Project_Flight;
using Sybase.Mobile;
using Sybase.Persistence;
using Sybase.Collections;


namespace Project_Flight
{
    public partial class Customer : Form
    {
        private const String USERNAME = "supAdmin";
        private const String PASSWORD = "nofear89";
        private const String HOST = "abdelrahman-pc";
        private const int PORT = 5001;
        private const int TIMEOUT = 600;
        public Customer()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Sybase.Mobile.Application app = Sybase.Mobile.Application.GetInstance();
            app.ApplicationIdentifier = "flight";
            // MyCallbackHandler.textBox1 = textBox1;
            //FlightDB.RegisterCallbackHandler(new MyCallbackHandler());
            FlightDB.SetApplication(app);
            FlightDB.GetSynchronizationProfile().ServerName = HOST;

            ConnectionProperties connProps = app.ConnectionProperties;
            LoginCredentials loginCredentials = new LoginCredentials(USERNAME, PASSWORD);

            connProps.LoginCredentials = loginCredentials;
            connProps.ServerName = HOST;
            connProps.PortNumber = PORT;

            if (app.RegistrationStatus != RegistrationStatus.REGISTERED)
            {
               
                app.RegisterApplication(TIMEOUT);
             
            }
            else
            {
               
                app.StartConnection(TIMEOUT);
           
            }
            if (!FlightDB.IsSynchronized("default"))
            {
                FlightDB.DisableChangeLog();
              
                FlightDB.Synchronize(); // Initial Synchronize

                ISynchronizationGroup sg = FlightDB.GetSynchronizationGroup("default");
                sg.EnableSIS = true;
                sg.Save();
                FlightDB.Synchronize();
       
            }
            MessageBox.Show("done");
            MBO_CustomerSynchronizationParameters cust = new MBO_CustomerSynchronizationParameters();
            cust.Sync_name = "abood";
            cust.Save();
            MBO_Customer customer =  cust.Create();
            FlightDB.Synchronize();

           
        }
    }
}